package com.lbb.socket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Server {
	
	Logger log = LoggerFactory.getLogger(Server.class);
	
	
	private ExecutorService threadPool = Executors.newFixedThreadPool(50);
	
	
	ThreadLocal<Socket> threadLocal = new ThreadLocal<Socket>();
	
	public static void main(String[] args) {
		
		new Server().run();
		
	}


	
	public void  run (){
		
		try {
			ServerSocket  server = new ServerSocket(8888);
			
			log.debug("socket 服务端已启动...............");
			
			
			while (true){
				
				Socket  request  = server.accept();
				
				
				threadPool.execute(new RequestHandler(request));
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		} 
		
	}
	

}
